package org.custom.spring.boot.datasource.interceptor;

import org.custom.spring.boot.datasource.manager.DataSourceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 动态数据源处理拦截器
 *
 * @author 李坤
 * @date 2022/4/3 0:47
 */
@Component
public class DynamicDataSourceInterceptor implements HandlerInterceptor {
    private final Logger logger = LoggerFactory.getLogger(DynamicDataSourceInterceptor.class);

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) throws Exception {
        DataSourceManager.clear();
    }
}
